package thread;

import java.io.IOException;

public class SyncDemo2 {
    public static void main(String[] args) {
    }
}

class Shop {
    public void buy() {
        try {
            Thread t = Thread.currentThread();
            System.out.println(t.getName() + ":正在挑选衣服...");
            Thread.sleep(5000);
            synchronized (this) {
                System.out.println(t.getName() + ":正在试穿衣服...");
                Thread.sleep(5000);
            }
            System.out.println(t.getName() + ":结账离开");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

